package com.bnz.controller;

import com.bnz.SecurityApplication;
import com.bnz.entity.R;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController

public class UserController {
    @GetMapping("/")
    public R login(){
        //获取用户名
        String name = SecurityContextHolder.getContext().getAuthentication().getName();

        return R.ok().data("name",name);
    }
    @RequestMapping("/success")
    public String success(){
        return "success";
    }
}
